package com.sky.controller.common;

import com.sky.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("adminShopController")
@RequestMapping("/admin/shop")
public class ShopController {


    public  static  final String KEY = "SHOP_STATUS";


    @Autowired
    private RedisTemplate redisTemplate;

    //获取营业状态
    @GetMapping("/status")
    public Result<Integer> getStatus(){
        System.out.println("123");
        //获取redis中的值
        Integer status = (Integer) redisTemplate.opsForValue().get(KEY);
        return Result.success(status);
    }
     //修改营业状态
    @PutMapping("/{status}")
    public Result startOrStop(@PathVariable Integer status){
        System.out.println(status);
        //将状态保存到redis中
        redisTemplate.opsForValue().set(KEY,status);
        return Result.success(status);
    }





}
